<%-- 
    Document   : profil
    Created on : 8-Apr-2012, 8:49:39 PM
    Author     : James
--%>

<%@page import="java.awt.image.RenderedImage"%>
<%@page import="java.io.OutputStream"%>
<%@page import="javax.imageio.ImageIO"%>
<%@page import="java.io.ByteArrayOutputStream"%>
<%@page import="javax.swing.JLabel"%>
<%@page import="java.awt.Color"%>
<%@page import="java.awt.Graphics"%>
<%@page import="java.awt.image.BufferedImage"%>
<%@page import="application.VillePaysBean"%>
<%@page import="java.util.List"%>
<%@page import="application.Facade"%>
<%@page import="application.MembreBean"%>
<%@page import="controleur.ConstantesWeb"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Profil</title>
        <link rel="stylesheet" type="text/css" href="<%=ConstantesWeb.CSS_ENTETE%>"/>
        <script type="text/javascript" src="Validation/modifierProfil.js"></script>
    </head>
    <body bgcolor="66CC99">
        <%
            Facade f = new Facade();
            MembreBean m;

            m = f.getMembre(request.getCookies());

            if (m == null) {
                out.print("<h1 align=\"center\">Erreur</h1>");
                return;
            }
        %>
        <jsp:include page="<%=ConstantesWeb.PAGE_ENTETE%>"/>
        <h1 align="left">Votre profil</h1>

        <FORM name="modifierProfil" METHOD="POST" ACTION="./Entree" onsubmit="return validerForme('modifierProfil')">
            <input type="hidden" name="cmd" value="<%=ConstantesWeb.CMD_MODIFIER_PROFIL%>"/>
            <input type="hidden" name="idMembre" value="<%=m.getIdMembre()%>"/>
            <input type="hidden" name="nomUtilisateur" value="<%=m.getNomUtilisateur()%>"/>
            <table width="800" border="0">
                <tr>
                    <td align="left">Nom d'utilisateur :</td>
                    <td align="right">
                        <input type="text" name="username" maxlength="<%=ConstantesWeb.BD_STRING_LENGTH%>" size="<%=ConstantesWeb.BD_STRING_LENGTH%>" 
                               disabled="disabled" value="<%=m.getNomUtilisateur()%>">
                    </td>
                    <td width="250" rowspan="11" align="center">
                        <input type="hidden" name="idImage" value="<%=m.getIdImage()%>"/>

                        <a href="#" onclick="document.forms['<%=ConstantesWeb.CMD_IMAGE%>'].submit();">
                            <img src="./<%=ConstantesWeb.PAGE_IMAGE%>?<%=ConstantesWeb.VALEUR_IMAGE_ID%>=<%=m.getIdImage()%>" height="150" width="150" align="center"/>
                        </a>
                    </td>
                </tr>            
                <tr>
                    <td align="left">Type de compte :</td>
                    <td align="right">
                        <input type="text" name="compte" maxlength="<%=ConstantesWeb.BD_STRING_LENGTH%>" size="<%=ConstantesWeb.BD_STRING_LENGTH%>" 
                               disabled="disabled" value="<%=f.getTypeValeur(m.getIdCompte())%>">
                    </td>
                </tr>
                <tr>                
                    <td align="left"><br>Prénom :</td>
                    <td align="right">
                        <br><input type="text" name="prenom" maxlength="<%=ConstantesWeb.BD_STRING_LENGTH%>" size="<%=ConstantesWeb.BD_STRING_LENGTH%>" 
                                   value="<%=m.getPrenom()%>">
                    </td>
                </tr>
                <tr>
                    <td align="left">Nom :</td>
                    <td align="right">
                        <input type="text" name="nom" maxlength="<%=ConstantesWeb.BD_STRING_LENGTH%>" size="<%=ConstantesWeb.BD_STRING_LENGTH%>" 
                               value="<%=m.getNomFamille()%>">
                    </td>
                </tr>
                <tr>
                    <td align="left">Courriel :</td>
                    <td align="right">
                        <input type="text" name="courriel" maxlength="<%=ConstantesWeb.BD_STRING_LENGTH%>" size="<%=ConstantesWeb.BD_STRING_LENGTH%>" 
                               value="<%=m.getCourriel()%>">
                    </td>
                </tr>
                <tr>
                    <td align="left">Adresse :</td>
                    <td align="right">
                        <input type="text" name="adresse" maxlength="<%=ConstantesWeb.BD_STRING_LENGTH%>" size="<%=ConstantesWeb.BD_STRING_LENGTH%>" 
                               value="<%=m.getAdresse()%>">
                    </td>
                </tr>
                <tr>
                    <td align="left">Téléphone :</td>
                    <td align="right">
                        <input type="text" name="telephone" maxlength="<%=ConstantesWeb.BD_STRING_LENGTH%>" size="<%=ConstantesWeb.BD_STRING_LENGTH%>" 
                               value="<%=m.getTelephone()%>">
                    </td>
                </tr>
                <tr>
                    <td align="left">Nouveau mot de passe :</td>
                    <td align="right">
                        <input type="password" name="pwd-nouveau-1" maxlength="<%=ConstantesWeb.BD_STRING_LENGTH%>" size="<%=ConstantesWeb.BD_STRING_LENGTH%>">
                    </td>
                </tr>
                <tr>
                    <td align="left">Confirmer mot de passe :</td>
                    <td align="right">
                        <input type="password" name="pwd-nouveau-2" maxlength="<%=ConstantesWeb.BD_STRING_LENGTH%>" size="<%=ConstantesWeb.BD_STRING_LENGTH%>">
                    </td>
                </tr>
                <tr>
                    <td align="left">Image (ex. C:\Images\) :</td>
                    <td align="right">
                        <input type="text" name="image_profil" size="<%=ConstantesWeb.BD_STRING_LENGTH%>"/>
                    </td>
                </tr>
                <tr>
                    <td align="left">Ville :</td>
                    <td align="right">
                        <select lenght="45" name="idVillePays">
                            <%
                                List<VillePaysBean> villesPaysBeanListe = f.getVillesPays();

                                for (VillePaysBean vp : villesPaysBeanListe) {
                                    out.print("<option value=\"" + vp.getIdVillePays() + "\"");

                                    if (vp.getIdVillePays().equals(m.getIdVille())) {
                                        out.print("selected=\"selected\"");
                                    }
                                    out.print(">" + vp.getVille() + ", " + f.getTypeValeur(vp.getIdPays()));
                                }
                            %>
                        </select>
                    </td>
                </tr>
                <tr>                
                    <td align="right" colspan="2">
                        <br>
                        Pour toute modification, entrer mot de passe présent.
                        <br>
                        <input type="password" name="pwd-ancien" maxlength="<%=ConstantesWeb.BD_STRING_LENGTH%>" size="<%=ConstantesWeb.BD_STRING_LENGTH%>">
                        <br>
                        <button>Sauvegarder</button>                    
                    </td>
                    <td></td>
                </tr>
            </table>
        </FORM>
        <FORM name="<%=ConstantesWeb.CMD_IMAGE%>" METHOD="POST" ACTION="./Entree">
            <input type="hidden" name="idImage" value="<%=m.getIdImage()%>"/>
            <input type="hidden" name="cmd" value="<%=ConstantesWeb.CMD_IMAGE%>"/>
        </FORM> 
    </body>
</html>
